﻿using Polly;

namespace Services.Initial.PublicProject.PublicMethods;

public class PollyExtension
{
    /// <summary>
    /// 创建重试策略
    /// </summary>
    /// <returns></returns>
    public static Policy CreateRetryPolicy()
    {
        return Policy.Handle<Exception>().WaitAndRetryForever(
            sleepDurationProvider: _ => TimeSpan.FromSeconds(10),
            onRetry: (exception, retry, _) => {
                Console.WriteLine(
                    "Exception {0} with message {1} detected during database migration (retry attempt {2})",
                    exception.GetType().Name, exception.Message, retry);
            });
    }

}
